package com.liu.common.entity;

import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class ResponseResult<T> extends BaseEntity {

    /**
     * 返回状态码
     */
    private Integer code;

    /**
     * 返回信息
     */
    private String msg;

    /**
     * 返回内容
     */
    private T data;

    public ResponseResult() {
    }

    public ResponseResult(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static <T> ResponseResult<T> OK() {
        return new ResponseResult<>(200, "请求成功", null);
    }

    public static <T> ResponseResult<T> OK(T data) {
        return new ResponseResult<>(200, "请求成功", data);
    }

    public static <T> ResponseResult<T> OK(String msg) {
        return new ResponseResult<>(200, msg, null);
    }

    public static <T> ResponseResult<T> FAIL(String msg) {
        return new ResponseResult<>(500, msg, null);
    }
}
